package com.example.g7640.controller;


import com.example.g7640.builder.ResultBuilder;
import com.example.g7640.dto.common.Result;
import com.example.g7640.entity.Score;
import com.example.g7640.service.ScoreService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * <p>
 * 前端控制器
 * </p>
 *
 * @author
 * @since 2024-03-18
 */
@RestController
@RequestMapping("/api/score")
public class ScoreController {

    @Resource
    ScoreService scoreService;

    @PostMapping("/add")
    public Result<Boolean> add(@RequestBody Score score) {
        return ResultBuilder.buildSuccess(scoreService.add(score));
    }

    @GetMapping("/get-vendor-avg")
    public Result<Double> getAvg(Integer vid) {
        return ResultBuilder.buildSuccess(scoreService.getAvg(vid));
    }
}
